package po;

import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import org.openqa.selenium.WebElement;
import utils.WaitUtils;

/**
 * 搜索页面
 */
public class SearchPage {
    AndroidDriver driver;

    public SearchPage(AndroidDriver driver) {
        this.driver = driver;
    }

    public LineDetailPage searchHistoryToLineDetail(String key) {
        MobileElement el2 = (MobileElement) driver.findElementById("com.ygkj.chelaile.standard:id/cll_apt_search_line_end");
        el2.click();
        WaitUtils.sleep(4);
        return new LineDetailPage(driver);
    }

    public LineDetailPage searchToLineDetail(String key) {
        WebElement elSearch = driver.findElementById("com.ygkj.chelaile.standard:id/frame_toolbar_search_query");
        elSearch.sendKeys(key);
        WaitUtils.sleep(4);
        MobileElement el3 = (MobileElement) driver.findElementByXPath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.ViewFlipper/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.ListView/android.view.ViewGroup[1]/android.widget.LinearLayout/android.widget.RelativeLayout/android.widget.LinearLayout/android.widget.LinearLayout[1]/android.widget.LinearLayout");
        el3.click();
        WaitUtils.sleep(4);
        return new LineDetailPage(driver);
    }
}
